home *** CD-ROM | disk | FTP | other *** search
- Path: RRZ.Uni-Koeln.DE!usenet
- From: a2867001@smail.rrz.Uni-Koeln.DE (Lars Kaderali)
- Newsgroups: comp.lang.c++
- Subject: Error?
- Date: Sun, 07 Jan 1996 20:33:28 GMT
- Organization: Regional Computing Center, University of Cologne
- Message-ID: <4cpaov$241@news.rrz.uni-koeln.de>
- NNTP-Posting-Host: annexr2-8.slip.uni-koeln.de
- X-Newsreader: Forte Free Agent v0.55
-
- Hey folks! Need some help - I tried the following program in c++ on an
- ibm pc:
-
- =======================================
-
- //test
- #include <iostream.h>
- float a,b;
- main()
- {
- a=-1.0; b=0.1;
- while (a<1.1)
- {
- cout<<a<<endl;
- a+=b;
- }
- }
-
- =======================================
-
- which returns:
-
- -1
- -0.9
- -0.8
- -0.7
- -0.6
- -0.5
- -0.4
- -0.3
- -0.2
- -0.1
- (so far as expected, but then:)
- 7.450581e-08 < ==== ??????????????
- 0.1
- 0.2
- 0.3
- 0.4
- 0.5
- 0.6
- 0.7
- 0.8
- 0.9
- 1
-
- How come this 7.450581e-08 happens instead of 0.0 ?????
- Please reply directly via e-mail if you know to help!!!
- Thanx a lot!
-
- Lars
-
-